package com.example.javaproject.okhttp;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class PriorityThreadPool {
    private static PriorityThreadPool threadPool;
    private ExecutorService executorService;

    private PriorityThreadPool() {
        executorService = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors() * 3);
    }

    public static PriorityThreadPool getInstance() {
        if (threadPool == null) {
            synchronized (PriorityThreadPool.class) {
                if (threadPool == null) threadPool = new PriorityThreadPool();
            }
        }
        return threadPool;
    }

    public void execute(Runnable runnable) {
        if (runnable == null) return;
        executorService.execute(runnable);
    }

    public void logExecutorInfo() {
    }
}
